package cn.shiwei.hr.fegin.search;

import cn.shiwei.hr.doc.CourseDoc;
import cn.shiwei.hr.repository.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SearchFeginClientFallBackFactory implements FallbackFactory<SearchFeginClient> {
    @Override
    public SearchFeginClient create(Throwable throwable) {
        return new SearchFeginClient() {
            @Override
            public AjaxResult saveCourse(CourseDoc doc) {
                log.error("远程调用检索中心, 课程上线发生异常:{}", throwable);
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("远程调用检索中心, 课程上线发生异常");
            }

            @Override
            public AjaxResult deleteCourseById(Long id) {
                log.error("远程调用检索中心, 课程下线发生异常:{}", throwable);
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("远程调用检索中心, 课程下线发生异常");
            }
            /*@Override
            public AjaxResult onLineCours(Long id) {
                log.error("远程调用检索中心, 课程上线发生异常:{}", throwable);
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("远程调用检索中心, 课程上线发生异常");
            }*/
        };
    }
}
